﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace WindowsGame1
{
    class SceneManager
    {
        public static List<Scene> scenes = new List<Scene>();
        public static List<Scene> scenesToRemove = new List<Scene>();
        public static List<Scene> scenesToAdd = new List<Scene>();
       // public List<Scene> scenes = List<Scene>();
        //public List<Scene> scenesToRemove = List<Scene>();
        //public List<Scene> scenesToAdd = List<Scene>();
        public static void update(int dTime, InputManager Input)
        {
            foreach (Scene s in scenes)
            {
                s.update(dTime);
                s.handleInput(Input);
                if (s.readyToExit)
                    scenesToRemove.Add(s);
            }
            foreach (Scene s in scenesToAdd)
            {
                scenes.Add(s);
            }
            foreach (Scene s in scenesToRemove)
            {
                scenes.Remove(s);
            }
            scenesToAdd.Clear();
            scenesToRemove.Clear();
        }

        public static void draw()
        { 
            foreach (Scene scene in scenes){
                scene.draw();
            }

        }
    }


}
